package com.idstaa;

import com.idstaa.service.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FilterConsumerMain {
    public static void main(String[] args) throws IOException, InterruptedException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        HelloService service = context.getBean(HelloService.class);

        ExecutorService executor = Executors.newFixedThreadPool(5);
        while (true) {
            Thread.sleep(100);
            for (int i = 0; i < 5; i++) {
                executor.submit(() -> {
                    String msg1 = service.sayHello("world");
                    String msg2 = service.sayGood("world");
                    String msg3 = service.sayOK("world");
                });
            }
        }
    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan(basePackages = "com.idstaa.bean")
    @EnableDubbo
    static class ConsumerConfiguration {
    }
}
